﻿package mortal.game.scene3D.layer3D
{
    import baseEngine.core.*;
    import baseEngine.system.*;
    import com.gengine.resource.*;
    import com.gengine.resource.info.*;
    import frEngine.primitives.*;
    import mortal.game.scene3D.map3D.*;
    import mortal.game.scene3D.model.player.*;

    public class BottomMapLayer extends SLayer3D
    {
        private var layerQuad:FrQuad;
        private var _effectPlayer:EffectPlayer;
        public var _bgMapWidth:Number = 2000;
        public var _bgMapHeight:Number = 2000;
        public var _offsetX:Number = 0;
        public var _offsetY:Number = 0;
        private var _bgMapId:String;
        private var _bitmapSelfMoveXSpeed:Number = 0.25;
        private var _curMoveX:Number = 0;
        private var _autoMove:Boolean = true;
        public var _curMapTexture:Texture3D;
        public static const instance:BottomMapLayer = new BottomMapLayer;

        public function BottomMapLayer()
        {
            super("");
            this._curMapTexture = new Texture3D(null, 0, TextureFormat.FORMAT_COMPRESSED, LoaderPriority.LevelA);
            this._curMapTexture.loadedAndUpload = true;
            return;
        }// end function

        public function reUpload() : void
        {
            this._curMapTexture.reUpload();
            return;
        }// end function

        public function resetBgMapInfo(param1:String, param2:uint, param3:uint, param4:String, param5:Boolean, param6:uint = 1024, param7:uint = 512) : void
        {
            if (param1 == this._bgMapId || !Global3D.loadResource)
            {
                return;
            }
            var _loc_8:* = ResourceManager.getInfoByName(this._bgMapId + ".abc");
            if (_loc_8)
            {
                _loc_8.dispose();
            }
            this._bgMapWidth = param2;
            this._bgMapHeight = param3;
            this._bgMapId = param1;
            this._autoMove = param5;
            _loc_8 = ResourceManager.getInfoByName(this._bgMapId + ".abc");
            if (!_loc_8)
            {
                _loc_8 = new ImageInfo();
                _loc_8.name = this._bgMapId + ".abc";
                _loc_8.type = ".abc";
                var _loc_9:* = "assets/3D/bgMaps/" + this._bgMapId + ".abc?v=" + param4;
                _loc_8.loaclPath = "assets/3D/bgMaps/" + this._bgMapId + ".abc?v=" + param4;
                _loc_8.path = _loc_9;
                ResourceManager.addResource(_loc_8);
            }
            this._curMapTexture.request = _loc_8.name;
            this._curMoveX = 0;
            return;
        }// end function

        public function randomBgSpeed() : void
        {
            this._bitmapSelfMoveXSpeed = Math.random() > 0.5 ? (0.25) : (-0.25);
            return;
        }// end function

        public function init() : void
        {
            return;
        }// end function

        override public function update(param1:int = 0) : void
        {
            if (this.timerContorler.curFrame == _preFrame)
            {
                return;
            }
            super.update(param1);
            if (this._autoMove)
            {
                this._curMoveX = this._curMoveX + this._bitmapSelfMoveXSpeed;
            }
            var _loc_2:* = Global3D.scene.viewPort.width;
            var _loc_3:* = Global3D.scene.viewPort.height;
            var _loc_4:* = SceneRange.displayInt.x + _loc_2 / 2;
            var _loc_5:* = SceneRange.displayInt.y + _loc_3 / 2;
            this._offsetX = this._curMoveX + _loc_4;
            this._offsetY = _loc_5;
            return;
        }// end function

    }
}
